class Post < ActiveRecord::Base
  belongs_to :user
  has_many :likes ,dependent: :destroy
  has_many :tags,dependent: :destroy

  validates :user_id,presence: true
  validates :content,presence: true,length: {maximum: 140}

	scope :tagged,(lambda do |tag|
		joins(:tags).where('tags.name = ?',tag).group('posts.id')
	             end)

end
